<?php

require_once '../mysqlConnect.php';

function getDropDownOptions ($id) {

	$conn = GetPDOConnection();

	try {
		$sql = "SELECT * FROM answer_options WHERE id = :id ORDER BY type";
		$STH = $conn->prepare($sql);
		$STH->bindParam(':id', $id);
		$STH->execute();
		$results = $STH->fetchAll(PDO::FETCH_ASSOC);
		return $results;
	} catch (PDOException $e) {
		return $e->getMessage();
	}
}

# get type options via a question table
function getTypeOptions($qnumber, $tablename) {

	$conn = GetPDOConnection();

	try {
		$sql = "SELECT type_options from $tablename WHERE qnumber = :qnumber ";
		$STH = $conn->prepare($sql);
		$STH->bindParam(':qnumber', $qnumber);
		$STH->execute();
		$results = $STH->fetch(PDO::FETCH_ASSOC);

		$options = getDropDownOptions($results['type_options']);

		return $options;

	} catch (PDOException $e) {
		echo $e->getMessage();
	}
}